ResourceNodeReader.Dependencies Property

Returns the ReadOnlyCollection<ResourceNodeReader> containing the resources this resource is dependent upon.

Parent Type: ResourceNodeReader

Namespace: Microsoft.LearningComponents.Manifest

Assembly: Microsoft.LearningComponents.dll

Syntax
C#

public ReadOnlyCollection<ResourceNodeReader> Dependencies

{ get; }
Exceptions
Exception type Condition
InvalidPackageException

In ManifestReaderSettings.FixScormRequirementViolations=false if there is an invalid node.

Remarks

To build this list, the identifierref attributes on the <dependency> nodes inside this <resource> node are cross-referenced with the identifier attributes on the <resource> nodes within this manifest.

The ReadOnlyCollection returned from this property is populated upon calling this property. E.g. non-trivial processing time is required.

In ManifestReaderSettings.FixScormRequirementViolations=true, warnings are added to the log and invalid nodes are ignored.

If there are no nodes of the specified type, an empty ReadOnlyCollection is returned.

Note that this only includes dependencies that are one layer deep. E.g. if resource A has resource B as a dependency, resource B is included in the list of dependencies for resource A. However, if resource B has a dependency on resource C, resource C is not included in the list of dependencies for resource A. An application can recursively call each ResourceNodeReader dependency list, but care must be taken for circular dependencies to avoid a code-deadlock. E.g. if resource A has resource B as a dependency, but resource B has resource A as a dependency, there is a circular dependency.

Example

Given an ActivityNodeReader, iterate through all dependencies on all resources on all child activities.

C#
            foreach (ActivityNodeReader child in activity.ChildActivities)
            {
                ResourceNodeReader resource = child.Resource;
                if (resource != null)
                {
                    foreach (ResourceNodeReader dependency in resource.Dependencies)
                    {
                        // Use the ResourceNodeReader if not null
                    }
                }
            }